package cn.okcmd.aboutRedis;

import lombok.extern.slf4j.Slf4j;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisSentinelPool;

import java.util.HashSet;
import java.util.Set;

/**
 * create by caoqg on 2021/10/28
 * 功能说明:
 */
@Slf4j
public class MySentinelTest {
    static JedisSentinelPool pool = null;
    static {
        Set<String> sentinelSockets = new HashSet<>();
        sentinelSockets.add("localhost:26379");
        sentinelSockets.add("localhost:26380");
        sentinelSockets.add("localhost:26381");
        pool = new JedisSentinelPool("mymaster", sentinelSockets);
    }
    public static void main(String[] args) {
        Jedis resource = pool.getResource();
        String key = "abc";

        resource.set(key,"123");
        String abc = resource.get(key);
        log.info("the key:{},value:{}",key,abc);
        resource.close();
    }
}
